#include "fthelpwidget.h"
#include "ftshowtext.h"

FTHelpWidget::FTHelpWidget(const QString& h, const QSize& s, QWidget *parent) :
    FTPushButton( QIcon(":/icons/help.png"), s, parent)
{
    setBackground( QBrush( QColor(), Qt::NoBrush ) );
    setHelp(h);
    connect( this, SIGNAL(clicked()),
             this, SLOT(showHelp()) );
}

void FTHelpWidget::setHelp(const QString & h)
{
    help_text = h;
}

void FTHelpWidget::showHelp()
{
    QDialog dialog(this);
    FTPushButton* ftp = new FTPushButton( tr("Close help" ) );
    FTShowText* te = new FTShowText( help_text );
    te->setCurrentFont( QFont( "Times", 8 ));

    connect( ftp, SIGNAL(clicked()),
             &dialog, SLOT(close()) );

    QVBoxLayout* grid = new QVBoxLayout( &dialog );
    grid->addWidget( te );
    grid->addWidget( ftp );
    dialog.showFullScreen();
    dialog.exec();
}
